import * as yaml from 'yaml';
import { readFileSync } from 'fs';
import { join } from 'path';

const env = process.env.NODE_ENV;
const file = `config.${env}.yml`;

type Config = {
  mysql: {
    host: string;
    port: number;
    username: string;
    password: string;
    database: string;
  },
  redis: {
    host: string;
    port: number;
    password: string
  },
  redisDb: {
    session: number;
    weather: number;
  },
  cookie: {
    maxAge: number,
    secure: false,
  },
  keys: string,
}
const config: Config = yaml.parse(readFileSync(join(__dirname, file), { encoding: 'utf8' }));
export default config;
